package cn.tansanqinger.dao.sql.hymenu;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.tansanqinger.dao.sql.IHyMenuMessage;
import cn.tansanqinger.pojo.HyMenu;

/**
 * 查询Hy_Menu数据
 * @author C3H2
 * @time 2021.01
 */
@Repository
public class HyMenuMessageDispose {
	
	@Autowired 
	private IHyMenuMessage message;
	
	/**
	 * 查询一级菜单信息
	 * @return
	 */
	public List<HyMenu> selectFirstHyMenus() {
		QueryWrapper<HyMenu> queryWrapper = new QueryWrapper<HyMenu>();
		queryWrapper.lambda().eq(HyMenu::getHparentId, 0).eq(HyMenu::getIsOnSale, 1);
		return message.selectList(queryWrapper);
	}
	
	/**
	 * 通过hparentId查询菜单信息
	 * @param hparentId
	 * @return
	 */
	public List<HyMenu> selectSecondHyMenus(int hparentId) {
		QueryWrapper<HyMenu> queryWrapper = new QueryWrapper<HyMenu>();
		queryWrapper.and(wrapper -> wrapper.eq("hparent_id", hparentId).or().eq("hmenu_id", hparentId));
		queryWrapper.lambda().eq(HyMenu::getIsOnSale, 1);
		return message.selectList(queryWrapper);
	}
}
